package com.yxq.mdt.app.modules.socialcontact.presenter;

import com.yxq.mdt.app.base.BasePresenter;
import com.yxq.mdt.app.modules.socialcontact.bean.ByPageListBean;
import com.yxq.mdt.app.modules.socialcontact.bean.CircleTopicListBean;
import com.yxq.mdt.app.modules.socialcontact.bean.MainSocialContactBean;
import com.yxq.mdt.app.modules.socialcontact.bean.MainSocialHeadBean;
import com.yxq.mdt.app.modules.socialcontact.bean.SocialAllListMember;
import com.yxq.mdt.app.modules.socialcontact.model.MainSocialContactModel;
import com.yxq.mdt.app.net.ApiModel;

public class MainSocialHomeRecommendPresenter extends BasePresenter<mainSocialHomeRecommendContract.View, MainSocialContactModel> implements mainSocialHomeRecommendContract.Presenter {


    /**
     * 如果当前页面同时需要 Model 层和 View 层,则使用此构造函数(默认)
     *
     * @param rootView
     * @param model
     */
    public MainSocialHomeRecommendPresenter(mainSocialHomeRecommendContract.View rootView, MainSocialContactModel model) {
        super(rootView, model);
    }


    @Override
    public void getTopList(String groupId, int pageNum, int pageSize) {
        mBaseModel.getTopicList(groupId, pageNum, pageSize, new ApiModel.CommonCallback<CircleTopicListBean>() {
            @Override
            public void onSuccess(CircleTopicListBean circleTopicListBean) {
                mRootView.onLoadTopListSuccess(circleTopicListBean);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadTopListFailed();
            }
        });
    }

    @Override
    public void setApplyGroup(String groupId) {
        mBaseModel.setApplyGroup(groupId, new ApiModel.CommonCallback<String>() {
            @Override
            public void onSuccess(String s) {
                mRootView.onLoadApplyGroupSuccess(s);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadApplyGroupFailed();
            }
        });
    }

    @Override
    public void setIntroductionGroupMembers(String id) {
        mBaseModel.setIntroductionGroupMembers(id, new ApiModel.CommonCallback<String>() {
            @Override
            public void onSuccess(String s) {
                mRootView.onLoadIntroductionGroupMembersSuccess(s);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadIntroductionGroupMembersFailed();
            }
        });
    }


    @Override
    public void getQueryGroupMembers(int pageSize, String groupId, int pageNum) {
        mBaseModel.getQueryGroupMembers(pageSize, groupId, pageNum, new ApiModel.CommonCallback<SocialAllListMember>() {
            @Override
            public void onSuccess(SocialAllListMember socialAllListMember) {
                mRootView.onLoadQueryGroupMembersSuccess(socialAllListMember);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadQueryGroupMembersFailed();
            }
        });
    }


    @Override
    public void getRecommendGroupDetail(String id) {
        mBaseModel.getRecommendGroupDetail(id, new ApiModel.CommonCallback<MainSocialHeadBean>() {
            @Override
            public void onSuccess(MainSocialHeadBean mainSocialContactBean) {
                mRootView.onLoadRecommendGroupDetailSuccess(mainSocialContactBean);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadRecommendGroupDetailFailed();
            }
        });
    }
    @Override
    public void setInterestRelation(String toUserId, int enabled, int type) {
        mBaseModel.setInterestRelation(toUserId, enabled, type, new ApiModel.CommonCallback<String>() {
            @Override
            public void onSuccess(String s) {
                mRootView.onLoadRelationSuccess(s);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadRelationFailed();
            }
        });
    }
}
